package com.cc.cbdb.common.report;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


// 继承自SQLiteOpenHelper数据库类的子类
public class RecordSQLiteOpenHelper extends SQLiteOpenHelper {

    private static String name = "temp.db";
    private static Integer version = 1;

    public RecordSQLiteOpenHelper(Context context) {
        super(context, name, null, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        //历史记录表
        db.execSQL("create table person_names(id INTEGER primary key autoincrement,name varchar(50),times INTEGER default 1)");
        db.execSQL("create table ethnicity(id INTEGER primary key autoincrement,name varchar(50),times INTEGER default 1)");
        db.execSQL("create table institution(id INTEGER primary key autoincrement,name varchar(50),times INTEGER default 1)");
        db.execSQL("create table statusCode(id INTEGER primary key autoincrement,name varchar(50),times INTEGER default 1)");
        db.execSQL("create table kinship(id INTEGER primary key autoincrement,name varchar(50),times INTEGER default 1)");
        //查询记录表
        db.execSQL("create table q_personInfo(id INTEGER primary key,times INTEGER default 1)");
        db.execSQL("create table q_address(id INTEGER primary key,times INTEGER default 1)");
        db.execSQL("create table q_addrType(id INTEGER primary key,times INTEGER default 1)");
        db.execSQL("create table q_entryType(id INTEGER primary key,times INTEGER default 1)");
        db.execSQL("create table q_choronym(id INTEGER primary key,times INTEGER default 1)");
        db.execSQL("create table q_dy(id INTEGER primary key,times INTEGER default 1)");
        db.execSQL("create table q_enthnicity(id INTEGER primary key,times INTEGER default 1)");
        db.execSQL("create table q_appointment(id INTEGER primary key,times INTEGER default 1)");
        db.execSQL("create table q_inst(id INTEGER primary key,times INTEGER default 1)");
        db.execSQL("create table q_biogInst(id INTEGER primary key,times INTEGER default 1)");
        db.execSQL("create table q_status(id INTEGER primary key,times INTEGER default 1)");
        db.execSQL("create table q_kinship(id INTEGER primary key,times INTEGER default 1)");
        db.execSQL("create table q_careerchange(id INTEGER primary key,times INTEGER default 1)");
        db.execSQL("create table q_text(id varchar(50) primary key,times INTEGER default 1)");
        //特殊的两个类型，需要id和tempid形成双主键
        db.execSQL("create table q_assoc(id INTEGER,tempid INTEGER,times INTEGER default 1,primary key(id,tempid))");
        db.execSQL("create table q_office(id INTEGER,tempid INTEGER,times INTEGER default 1,primary key(id,tempid))");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }

}
